home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / suprloco.c < prev    next >
C/C++ Source or Header  |  2000-05-04  |  10KB  |  332 lines

  1. /******************************************************************************
  2.  
  3.  Super Locomotive
  4.  
  5. driver by Zsolt Vasvari
  6.  
  7.  TODO:
  8.  Bit 4 in suprloco_control_w is pulsed when loco turns "super"
  9.  
  10. ******************************************************************************/
  11.  
  12. #include "driver.h"
  13. #include "vidhrdw/system1.h"
  14. #include "cpu/z80/z80.h"
  15.  
  16.  
  17. extern unsigned char *spriteram;
  18. extern size_t spriteram_size;
  19.  
  20. extern unsigned char *suprloco_videoram;
  21.  
  22. void suprloco_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
  23. int  suprloco_vh_start(void);
  24. void suprloco_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  25. WRITE_HANDLER( suprloco_videoram_w );
  26. WRITE_HANDLER( suprloco_scrollram_w );
  27. READ_HANDLER( suprloco_scrollram_r );
  28. WRITE_HANDLER( suprloco_control_w );
  29. READ_HANDLER( suprloco_control_r );
  30.  
  31.  
  32. /* in machine/segacrpt.c */
  33. void suprloco_decode(void);
  34.  
  35.  
  36. static WRITE_HANDLER( suprloco_soundport_w )
  37. {
  38.     soundlatch_w(0,data);
  39.     cpu_cause_interrupt(1,Z80_NMI_INT);
  40.     /* spin for a while to let the Z80 read the command (fixes hanging sound in Regulus) */
  41.     cpu_spinuntil_time(TIME_IN_USEC(50));
  42. }
  43.  
  44.  
  45. static struct MemoryReadAddress readmem[] =
  46. {
  47.     { 0x0000, 0xbfff, MRA_ROM },
  48.     { 0xc000, 0xc1ff, MRA_RAM },
  49.     { 0xc800, 0xc800, input_port_0_r },
  50.     { 0xd000, 0xd000, input_port_1_r },
  51.     { 0xd800, 0xd800, input_port_2_r },
  52.     { 0xe000, 0xe000, input_port_3_r },
  53.     { 0xe001, 0xe001, input_port_4_r },
  54.     { 0xe801, 0xe801, suprloco_control_r },
  55.     { 0xf000, 0xf6ff, MRA_RAM },
  56.     { 0xf7e0, 0xf7ff, suprloco_scrollram_r },
  57.     { 0xf800, 0xffff, MRA_RAM },
  58.     { -1 } /* end of table */
  59. };
  60.  
  61. static struct MemoryWriteAddress writemem[] =
  62. {
  63.     { 0x0000, 0xbfff, MWA_ROM },
  64.     { 0xc000, 0xc1ff, MWA_RAM, &spriteram, &spriteram_size },
  65.     { 0xe800, 0xe800, suprloco_soundport_w },
  66.     { 0xe801, 0xe801, suprloco_control_w },
  67.     { 0xf000, 0xf6ff, suprloco_videoram_w, &suprloco_videoram },
  68.     { 0xf7e0, 0xf7ff, suprloco_scrollram_w },
  69.     { 0xf800, 0xffff, MWA_RAM },
  70.     { -1 } /* end of table */
  71. };
  72.  
  73.  
  74. static struct MemoryReadAddress sound_readmem[] =
  75. {
  76.     { 0x0000, 0x7fff, MRA_ROM },
  77.     { 0x8000, 0x87ff, MRA_RAM },
  78.     { 0xe000, 0xe000, soundlatch_r },
  79.     { -1 } /* end of table */
  80. };
  81.  
  82. static struct MemoryWriteAddress sound_writemem[] =
  83. {
  84.     { 0x0000, 0x7fff, MWA_ROM },
  85.     { 0x8000, 0x87ff, MWA_RAM },
  86.     { 0xa000, 0xa003, SN76496_0_w },
  87.     { 0xc000, 0xc003, SN76496_1_w },
  88.     { -1 } /* end of table */
  89. };
  90.  
  91. static struct IOWritePort writeport[] =
  92. {
  93.     { Z80_HALT_PORT, Z80_HALT_PORT+1, MWA_NOP },    /* HALT ports */
  94.     { -1 }    /* end of table */
  95. };
  96.  
  97.  
  98. INPUT_PORTS_START( suprloco )
  99.     PORT_START    /* IN0 */
  100.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
  101.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
  102.     PORT_BITX(0x04, IP_ACTIVE_LOW, IPT_SERVICE, DEF_STR( Service_Mode ), KEYCODE_F2, IP_JOY_NONE )
  103.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN3 )
  104.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 )
  105.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 )
  106.     PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
  107.  
  108.     PORT_START    /* IN1 */
  109.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
  110.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY )
  111.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY )
  112.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY )
  113.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
  114.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
  115.     PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
  116.  
  117.     PORT_START    /* IN2 */
  118.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_COCKTAIL )
  119.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_COCKTAIL )
  120.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_COCKTAIL )
  121.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_COCKTAIL )
  122.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL )
  123.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL )
  124.     PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
  125.  
  126.     PORT_START  /* DSW1 */
  127.     PORT_DIPNAME( 0x07, 0x00, DEF_STR( Coin_A ) )
  128.     PORT_DIPSETTING(    0x07, DEF_STR( 5C_1C ) )
  129.     PORT_DIPSETTING(    0x06, DEF_STR( 4C_1C ) )
  130.     PORT_DIPSETTING(    0x05, DEF_STR( 3C_1C ) )
  131.     PORT_DIPSETTING(    0x04, DEF_STR( 2C_1C ) )
  132.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
  133.     PORT_DIPSETTING(    0x01, DEF_STR( 1C_2C ) )
  134.     PORT_DIPSETTING(    0x02, DEF_STR( 1C_3C ) )
  135.     PORT_DIPSETTING(    0x03, DEF_STR( 1C_6C ) )
  136.     PORT_DIPNAME( 0x38, 0x00, DEF_STR( Coin_B ) )
  137.     PORT_DIPSETTING(    0x38, DEF_STR( 5C_1C ) )
  138.     PORT_DIPSETTING(    0x30, DEF_STR( 4C_1C ) )
  139.     PORT_DIPSETTING(    0x28, DEF_STR( 3C_1C ) )
  140.     PORT_DIPSETTING(    0x20, DEF_STR( 2C_1C ) )
  141.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
  142.     PORT_DIPSETTING(    0x08, DEF_STR( 1C_2C ) )
  143.     PORT_DIPSETTING(    0x10, DEF_STR( 1C_3C ) )
  144.     PORT_DIPSETTING(    0x18, DEF_STR( 1C_6C ) )
  145.     PORT_DIPNAME( 0xc0, 0x40, DEF_STR( Lives ) )
  146.     PORT_DIPSETTING(    0x00, "2" )
  147.     PORT_DIPSETTING(    0x40, "3" )
  148.     PORT_DIPSETTING(    0x80, "4" )
  149.     PORT_DIPSETTING(    0xc0, "5" )
  150.  
  151.     PORT_START  /* DSW2 */
  152.     PORT_DIPNAME( 0x03, 0x00, DEF_STR( Bonus_Life ) )
  153.     PORT_DIPSETTING(    0x00, "20000" )
  154.     PORT_DIPSETTING(    0x01, "30000" )
  155.     PORT_DIPSETTING(    0x02, "40000" )
  156.     PORT_DIPSETTING(    0x03, "50000" )
  157.     PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unused ) )
  158.     PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
  159.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  160.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Free_Play ) )
  161.     PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
  162.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  163.     PORT_DIPNAME( 0x10, 0x10, DEF_STR( Difficulty ) )
  164.     PORT_DIPSETTING(    0x10, "Easy" )
  165.     PORT_DIPSETTING(    0x00, "Hard" )
  166.     PORT_BITX(    0x20, 0x20, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Infinite Lives", IP_KEY_NONE, IP_JOY_NONE )
  167.     PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
  168.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  169.     PORT_DIPNAME( 0x40, 0x40, "Initial Entry" )
  170.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  171.     PORT_DIPSETTING(    0x40, DEF_STR( On ) )
  172.     PORT_DIPNAME( 0x80, 0x00, DEF_STR( Cabinet ) )
  173.     PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
  174.     PORT_DIPSETTING(    0x80, DEF_STR( Cocktail ) )
  175.  
  176. INPUT_PORTS_END
  177.  
  178.  
  179. static struct GfxLayout charlayout =
  180. {
  181.     8,8,    /* 8 by 8 */
  182.     1024,    /* 1024 characters */
  183.     4,        /* 4 bits per pixel */
  184.     { 0, 1024*8*8, 2*1024*8*8, 3*1024*8*8 },            /* plane */
  185.     { 0, 1, 2, 3, 4, 5, 6, 7 },
  186.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
  187.     8*8
  188. };
  189.  
  190.  
  191. static struct GfxDecodeInfo gfxdecodeinfo[] =
  192. {
  193.     /* sprites use colors 0-255 */
  194.     { REGION_GFX1, 0x6000, &charlayout, 256, 16 },
  195.     { -1 } /* end of array */
  196. };
  197.  
  198.  
  199. static struct SN76496interface sn76496_interface =
  200. {
  201.     2,        /* 2 chips */
  202.     { 2000000, 4000000 },    /* 8 MHz / 4 ?*/
  203.     { 100, 100 }
  204. };
  205.  
  206.  
  207.  
  208. static struct MachineDriver machine_driver_suprloco =
  209. {
  210.     /* basic machine hardware */
  211.     {
  212.         {
  213.             CPU_Z80,
  214.             4000000,    /* 4 MHz (?) */
  215.             readmem,writemem,0,writeport,
  216.             interrupt,1
  217.         },
  218.         {
  219.             CPU_Z80 | CPU_AUDIO_CPU,
  220.             4000000,
  221.             sound_readmem,sound_writemem,0,0,
  222.             interrupt,4            /* NMIs are caused by the main CPU */
  223.         },
  224.     },
  225.     60, 5000,           /* frames per second, vblank duration */
  226.     1,                    /* single CPU, no need for interleaving */
  227.     0,
  228.  
  229.     /* video hardware */
  230.     32*8, 32*8,                /* screen_width, screen_height */
  231.     { 1*8, 31*8-1, 0*8, 28*8-1 },            /* struct rectangle visible_area */
  232.     gfxdecodeinfo,                /* GfxDecodeInfo */
  233.     512,                /* total colors */
  234.     512,                /* color table length */
  235.     suprloco_vh_convert_color_prom,        /* convert color prom routine */
  236.  
  237.     VIDEO_TYPE_RASTER,
  238.     0,                            /* vh_init routine */
  239.     suprloco_vh_start,            /* vh_start routine */
  240.     0,            /* vh_stop routine */
  241.     suprloco_vh_screenrefresh,    /* vh_update routine */
  242.  
  243.     /* sound hardware */
  244.     0,0,0,0,
  245.     {
  246.         {
  247.             SOUND_SN76496,
  248.             &sn76496_interface
  249.         }
  250.     }
  251. };
  252.  
  253.  
  254. /***************************************************************************
  255.  
  256.   Game driver(s)
  257.  
  258. ***************************************************************************/
  259.  
  260. ROM_START( suprloco )
  261.     ROM_REGION( 2*0x10000, REGION_CPU1 )    /* 64k for code + 64k for decrypted opcodes */
  262.     ROM_LOAD( "ic37.bin",     0x0000, 0x4000, 0x57f514dd )    /* encrypted */
  263.     ROM_LOAD( "ic15.bin",     0x4000, 0x4000, 0x5a1d2fb0 )    /* encrypted */
  264.     ROM_LOAD( "ic28.bin",     0x8000, 0x4000, 0xa597828a )
  265.  
  266.     ROM_REGION( 0x10000, REGION_CPU2 )    /* 64k for sound cpu */
  267.     ROM_LOAD( "ic64.bin",     0x0000, 0x2000, 0x0aa57207 )
  268.  
  269.     ROM_REGION( 0xe000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  270.     ROM_LOAD( "ic63.bin",     0x0000, 0x2000, 0xe571fe81 )
  271.     ROM_LOAD( "ic62.bin",     0x2000, 0x2000, 0x6130f93c )
  272.     ROM_LOAD( "ic61.bin",     0x4000, 0x2000, 0x3b03004e )
  273.                             /*0x6000- 0xe000 will be created by init_suprloco */
  274.  
  275.     ROM_REGION( 0x8000, REGION_GFX2 )    /* 32k for sprites data used at runtime */
  276.     ROM_LOAD( "ic55.bin",     0x0000, 0x4000, 0xee2d3ed3 )
  277.     ROM_LOAD( "ic56.bin",     0x4000, 0x2000, 0xf04a4b50 )
  278.                             /*0x6000 empty */
  279.  
  280.     ROM_REGION( 0x0620, REGION_PROMS )
  281.     ROM_LOAD( "ic100.bin",    0x0000, 0x0080, 0x7b0c8ce5 )  /* color PROM */
  282.     ROM_CONTINUE(             0x0100, 0x0080 )
  283.     ROM_CONTINUE(             0x0080, 0x0080 )
  284.     ROM_CONTINUE(             0x0180, 0x0080 )
  285.     ROM_LOAD( "ic89.bin",     0x0200, 0x0400, 0x1d4b02cb )  /* 3bpp to 4bpp table */
  286.     ROM_LOAD( "ic7.bin",      0x0600, 0x0020, 0x89ba674f )    /* unknown */
  287. ROM_END
  288.  
  289.  
  290.  
  291. void init_suprloco(void)
  292. {
  293.     /* convert graphics to 4bpp from 3bpp */
  294.  
  295.     int i, j, k, color_source, color_dest;
  296.     unsigned char *source, *dest, *lookup;
  297.  
  298.     source = memory_region(REGION_GFX1);
  299.     dest   = source + 0x6000;
  300.     lookup = memory_region(REGION_PROMS) + 0x0200;
  301.  
  302.     for (i = 0; i < 0x80; i++, lookup += 8)
  303.     {
  304.         for (j = 0; j < 0x40; j++, source++, dest++)
  305.         {
  306.             dest[0] = dest[0x2000] = dest[0x4000] = dest[0x6000] = 0;
  307.  
  308.             for (k = 0; k < 8; k++)
  309.             {
  310.                 color_source = (((source[0x0000] >> k) & 0x01) << 2) |
  311.                                (((source[0x2000] >> k) & 0x01) << 1) |
  312.                                (((source[0x4000] >> k) & 0x01) << 0);
  313.  
  314.                 color_dest = lookup[color_source];
  315.  
  316.                 dest[0x0000] |= (((color_dest >> 3) & 0x01) << k);
  317.                 dest[0x2000] |= (((color_dest >> 2) & 0x01) << k);
  318.                 dest[0x4000] |= (((color_dest >> 1) & 0x01) << k);
  319.                 dest[0x6000] |= (((color_dest >> 0) & 0x01) << k);
  320.             }
  321.         }
  322.     }
  323.  
  324.  
  325.     /* decrypt program ROMs */
  326.     suprloco_decode();
  327. }
  328.  
  329.  
  330.  
  331. GAME( 1982, suprloco, 0, suprloco, suprloco, suprloco, ROT0, "Sega", "Super Locomotive" )
  332.